package cn.itsource.system.service.impl;

import cn.itsource.system.domain.Permission;
import cn.itsource.system.query.PermissionQuery;
import cn.itsource.system.mapper.PermissionMapper;
import cn.itsource.system.service.PermissionService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PermissionServiceImpl implements PermissionService {
    
    @Autowired
    private PermissionMapper permissionMapper;


    @Override
    public void insert(Permission p) {
        permissionMapper.insert(p);
    }

    @Override
    public void updateByPrimaryKeySelective(Permission p) {
        permissionMapper.updateByPrimaryKeySelective(p);
    }



    @Override
    public PageInfo<Permission> pageInfo(PermissionQuery permissionQuery) {
        PageHelper.startPage(permissionQuery.getCurrentPage(),permissionQuery.getPageSize());
        List<Permission> permissions = permissionMapper.selectAll(permissionQuery);
        return new PageInfo<Permission>(permissions);
    }


    @Override
    public void deleteAll(List<Permission> p) {
        permissionMapper.deleteAll(p);
    }

    @Override
    public void deleteByPrimaryKey(Long id) {
        permissionMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<Permission> gettree() {

      return  permissionMapper.selectAllType();
    }
}
